Skip to content

Ship pre-compiled JS to avoid transpilation cost#27

Merged
shekohex merged 2 commits intoshekohex:mainfrom
JosXa:feat/ship-compiled-js
Apr 4, 2026
Merged

Ship pre-compiled JS to avoid transpilation cost#27
shekohex merged 2 commits intoshekohex:mainfrom
JosXa:feat/ship-compiled-js

Conversation

@JosXa
Copy link
Copy Markdown
Contributor

@JosXa JosXa commented Mar 10, 2026

Summary

  • Ship pre-compiled JS in the npm package so consumers don't pay Bun transpilation cost on every load
  • Follows the same pattern as opencode-snippets: tsc -p tsconfig.build.json emits to dist/, npm package ships only dist/
  • Fix import.meta.dir path resolution for static file serving when running from dist/

Changes

  • tsconfig.build.json — build config targeting dist/, with rewriteRelativeImportExtensions for Bun-style .ts imports
  • package.jsonmain/types/module point to dist/, new build:plugin script, prepublishOnly hook, files: ["dist"]
  • src/web/server/handlers/static.ts — strip trailing /dist from resolved module dir so static assets resolve correctly from both source and compiled output

@shekohex
Copy link
Copy Markdown
Owner

CI is failing, tests are failing.

@JosXa JosXa force-pushed the feat/ship-compiled-js branch from 5a2b486 to 4f29a20 Compare April 1, 2026 23:52
@shekohex
Copy link
Copy Markdown
Owner

shekohex commented Apr 3, 2026

Can you please rebase? We can ship this.

@JosXa JosXa force-pushed the feat/ship-compiled-js branch from 4f29a20 to 24b8a4a Compare April 3, 2026 22:05
@JosXa
Copy link
Copy Markdown
Contributor Author

JosXa commented Apr 4, 2026

Rebased onto current main, and the exact head passes CI on my fork: https://github.com/JosXa/opencode-pty/actions/runs/23964808350

"license": "MIT",
"type": "module",
"exports": {
"./server": "./index.ts",
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need the ./server entry point, otherwise opencode will reject it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Restored ./server on the latest head so the packaged plugin still exposes the entry point OpenCode expects.

@shekohex shekohex merged commit b41d333 into shekohex:main Apr 4, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants